<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 
<%@ page import="javax.sql.rowset.WebRowSet" %> 
<!DOCTYPE html> 
<html> 
<head> 
<meta charset="UTF-8"> 
<title>菜单</title> 
<style>
        body {
            background-color: #f5f5f5;
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
        }
        h2 {
            color: #666;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            background-color: #fff;
            margin-top: 20px;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 10px;
        }
        th {
            background-color: #f0f0f0;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        a {
            color: #337ab7;
            text-decoration: none;
        }
        a:hover {
            text-decoration: underline;
        }
        label {
            display: inline-block;
            width: 120px;
        }
        .container {
            padding: 20px;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        .button-delete {
            color: red;
        }
        input[type="submit"] {
            padding: 10px 20px;
            background-color: #337ab7;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
    </style>
</head> 
<body> 
<div class="container"> 
<h2>session数据</h2> 
<% 
String id = (String)session.getAttribute("id"); 
out.println("<br>管理者: " + session.getAttribute("account")); 
%> 
<h2>所有房源信息</h2> 
<table width="100%" border="1">
<tr>
<th>roomNumber</th>
<th>roomType</th>
<th>roomFacilities</th>
<th>specialServices</th>


<th width="10%">操作</th>
</tr>
<%
javax.sql.rowset.WebRowSet rs = com.myweb.DBTools.getRS("SELECT * FROM hotelavailabilityinformation");
while(rs.next()){
%>
<tr onclick="fillform(this)" style="cursor:pointer">
<td><%=rs.getString("roomNumber")%></td>
<td><%=rs.getString("roomType")%></td>
<td><%=rs.getString("roomFacilities")%></td>
<td><%=rs.getString("specialServices")%></td> 


<td>
<a href="edit.jsp?id=<%=rs.getString("roomNumber")%>">修改</a>
<a href="save1.jsp?btn=del&roomNumber=<%=rs.getString("roomNumber")%>" class="button-delete" onclick="return confirm('请确认是否删除当前记录？');">删除</a> 
</td>
</tr>
<%
}
rs.close();
%>
</table> 
<hr> 
<h2>新增房源信息</h2>
<form action="save1.jsp"method="post">
<label for="roomNumber">roomNumber:</label>
<input type="text" id="roomNumber" name="roomNumber" required><br><br>
<label for="roomtype">roomType:</label>
<select id="roomtype" value="1">
<option value="1">单人间</option>
<option value="2">双人间</option>
<option value="3">大床房</option>
<option value="4">钟点房</option>
</select> 

<label for="roomFacilities">roomFacilities:</label>
<input type="text" id="roomFacilities" name="roomFacilities" required><br><br>
<label for="specialServices">specialServices:</label>
<input type="text" id="specialServices" name="specialServices" required><br><br>
<br><br>

<input type="submit" name="btn" value="提交" ><br><br>
</form>

<script>
function fillform(row) {
console.info(row);
var tds = row.getElementsByTagName("td");
//填入表单
roomNumber.value=tds[0].innerText;
roomType.value=tds[1].innerText;
roomFacilities.value=tds[2].innerText;
specialServices.value=tds[3].innerText;

} 
</script>
</body>
</html>